package com.atqinke.designpattern.creationtype.constructor;

/**
 * @BelongsProject: BasicConnection
 * @BelongsPackage: com.atqinke.DesignPattern.creation.constructor
 * @Author: NieHk
 * @CreateTime: 2022-08-26  11:24
 * @Description: 建造者模式
 * @Version: 1.0
 */
public class Phone {
    private String cpu;
    private String screen;
    private String memory;
    private String brand;

    private Phone(Builder builder){
        cpu = builder.cpu;
        screen = builder.screen;
        memory = builder.memory;
        brand = builder.brand;
    }


    public static final class Builder{
        private String cpu;
        private String screen;
        private String memory;
        private String brand;

        public Builder(){}

        public Builder cpu(String val){
            cpu = val;
            return this;
        }
        public Builder memory(String val){
            memory = val;
            return this;
        }
        public Builder brand(String val){
            brand = val;
            return this;
        }
        public Builder screen(String val){
            screen = val;
            return this;
        }
        public Phone builder(){
            return new Phone(this);
        }

    }

    @Override
    public String toString() {
        return "Phone{" +
                "cpu='" + cpu + '\'' +
                ", screen='" + screen + '\'' +
                ", memory='" + memory + '\'' +
                ", brand='" + brand + '\'' +
                '}';
    }
}
